<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>Javascript的对象</h1>

<script>

    //1.json方式创建对象
    //创建了汽车对象，包含三个属性：品牌、型号、颜色
    /*
    let car = {type:"porsche", model:"911", color:"white"};

    console.log("品牌："+car.type);
    console.log("型号："+car.model);
    console.log("颜色："+car.color);
    console.log("价格:"+car.price);*/

    //2.如何添加和删除属性
    //创建了汽车对象，包含三个属性：品牌、型号、颜色

    /*
    let car = {type:"porsche", model:"911", color:"white"};

    console.log("品牌："+car.type);
    console.log("型号："+car.model);
    console.log("颜色："+car.color);
    console.log("价格:"+car.price);

    //添加价格属性
    car.price = 500000;
    console.log("价格:"+car.price);

    //删除品牌属性
    delete car.type;
    console.log("品牌："+car.type);*/

    //3.如何添加方法
    //创建了汽车对象，包含三个属性：品牌、型号、颜色
    let car = {
        type: "porsche",
        model: "911",
        color: "white",
        drive: function(){
            console.log(this.type+"牌,"+"型号为:"+this.model+",小汽车启动了...");
        }
    };

    car.drive();
</script>

</body>
</html>